//
//  YCProgressView.swift
//  weiBoSwift
//
//  Created by 刘胤辰 on 16/7/21.
//  Copyright © 2016年 it.com. All rights reserved.
//

import UIKit

class YCProgressView: UIProgressView {
    
    var timer:NSTimer?
//    var isLoaded:Bool?

    override init(frame: CGRect) {
        
        super.init(frame: CGRectMake(0, 64, SCREENW, 2))
        
        self.tintColor=UIColor.redColor()
    
    }
    
    //给外界提供是否要加载progress
    func startAnimination(){
        
        timer=NSTimer.scheduledTimerWithTimeInterval(1/30, target: self, selector: "valueChange", userInfo: nil, repeats: true)
    }
    
    // MARK : -- 设置progress加载
    @objc private func valueChange(){
        
        self.progress += 0.05
        
        if self.progress >= 0.95 {
            
            self.progress=0.95
        }
    }
    
    func stopAnimination(){
        
        self.progress=1
        
        timer?.invalidate()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
